<template>
	<div>
		<div id="components-form-demo-advanced-search">
			<!-- <a-form class="ant-advanced-search-form home-form" :form="form" @submit="handleSearch">
				<a-row :gutter="24">
					<a-col :span="8">
						<a-form-item label="时间"><a-range-picker v-decorator="['data']" /></a-form-item>
					</a-col>
					<a-col :span="8" style="margin-top:4px;">
						<a-button type="primary" html-type="submit" class="btn1">搜索</a-button>
						<a-button :style="{ marginLeft: '8px' }" @click="handleReset" class="btn2">重置</a-button>
					</a-col>
				</a-row>
			</a-form> -->
		</div>
		<div>
			<el-table :data="data" v-loading="loading" border :max-height="tableHeight" highlight-current-row style="width: 100%;">
				<el-table-column prop="Name" label="状态/名称" min-width="260" fixed="left">
					<template slot-scope="scope">
						<a-tag :color="scope.row.IsEnable ? 'red' : 'pink'">{{ scope.row.IsEnable ? '启用' : '停用' }}</a-tag>
						{{ scope.row.Name }}
					</template>
				</el-table-column>
				<el-table-column prop="Ico" label="图标" min-width="100">
					<template slot-scope="scope">
						<img style="width:60px;" :src="scope.row.Ico" />
					</template>
				</el-table-column>
				<el-table-column prop="TypeName" label="类型" min-width="180">
					<template slot-scope="scope">
						{{ scope.row.TypeName }}
					</template>
				</el-table-column>
				<el-table-column prop="DpeartName" label="所属部门" min-width="200"></el-table-column>
				<el-table-column prop="ChairmanNo" label="学生组织负责人" min-width="190">
					<template slot-scope="scope">
						<div>{{ scope.row.ChairmanNo + ' / ' + scope.row.CairmanName }}</div>
					</template>
				</el-table-column>
				<el-table-column prop="Desc" label="描述" min-width="80" show-overflow-tooltip=""></el-table-column>
				<el-table-column label="操作" width="190" fixed="right">
					<template slot-scope="scope">
						<i title="老师" class="iconfont icon-laoshi" style="color: green;" @click="seeList(scope.row, 'teacher')"></i>
						<i title="成员" class="iconfont icon-chengyuan" style="color: red;" @click="seeList(scope.row, 'user')"></i>
						<i title="公告" class="iconfont icon-gonggao" style="color: #1890FF;" @click="seeList(scope.row, 'notice')"></i>
					</template>
				</el-table-column>
			</el-table>
			<el-pagination
				@size-change="handleSizeChange"
				@current-change="handleCurrentChange"
				:current-page="pagination.currentPage"
				:page-sizes="pagination.pageSizeOptions"
				:page-size="pagination.pageSize"
				layout="total, sizes, prev, pager, next, jumper"
				:total="pagination.total"
			></el-pagination>
		</div>
	</div>
</template>

<script>
import moment from 'moment'
import { DoGetGuideClubStudentPageList } from '@/api/follow';
const data = [];
export default {
	components: {
	},
	data() {
		return {
			data,
			form: this.$form.createForm(this, {
				name: 'advanced_search'
			}),
			pagination: {
				currentPage: 1,
				pageSize: this.global.pageSize,
				pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
				showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
			},
			loading: false,
			values: {},
			tableHeight: parseFloat(window.innerHeight - 160),
		};
	},
	computed: {},
	created() {
		this.getList();
	},
	mounted() {},
	methods: {
		moment,
		handleSearch(e) {
			e.preventDefault();
			this.form.validateFields((error, values) => {
				this.pagination.currentPage = 1;
				if (values.data&&values.data.length>0) {
					values.startTime = values.data[0].format('YYYY-MM-DD')
					values.endTime = values.data[1].format('YYYY-MM-DD')
				}
				this.values = values;
				this.getList();
			});
		},
		handleReset() {
			this.form.resetFields();
			this.values = {};
			this.getList();
		},
		handleSizeChange(val) {
			this.pagination.pageSize = val;
			this.getList();
		},
		handleCurrentChange(val) {
			this.pagination.currentPage = val;
			this.getList();
		},
		async getList() {
			this.loading = true;
			let data = {};
			if (this.values) {
				data = this.values;
			}
			data.id = this.$route.query.ID
			data.pageIndex = this.pagination.currentPage;
			data.pageSize = this.pagination.pageSize;
			let res = await DoGetGuideClubStudentPageList(data);
			this.loading = false;
			this.data = res.data.data;
			const pagination = { ...this.pagination };
			pagination.total = res.data.pageInfo.TotalItemCount;
			this.pagination = pagination;
		},
		seeList(text, name) {
			let path = '';
			if (name == 'teacher') {
				path = 'ClubTeacher';
			} else if (name == 'manage') {
				path = 'ClubManagerList';
			} else if (name == 'notice') {
				path = 'ANoticeJoin';
			} else {
				path = 'ClubMember';
			}
			this.$router.push({
				name: path,
				query: {
					ID: text.ID,
					Name: text.Name
				}
			});
		},
	}
};
</script>

<style lang="less" scoped>
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;

	/deep/.ant-form-item-label {
		width: 80px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		text-align: right;
	}
	/deep/.ant-form-item-control-wrapper {
		flex: 1;
		/deep/.ant-calendar-picker{
			width:100%
		}
	}
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
</style>
